<template>
  <basic-container>
    <avue-crud
      :option="option"
      :search.sync="search"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      :before-open="beforeOpen"
      v-model="form"
      ref="crud"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @sort-change="sortChange"
    >
    <!-- @on-load="onLoad" -->

      <template slot="menuLeft">
        <avue-data-display :option="cardOption"></avue-data-display>
      </template>

      <template slot="menuRight">
        <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          @click="handleExport"
          >导出
        </el-button>
      </template>

      <template slot-scope="scope" slot="menu">
        <el-button size="small" type="text" @click.stop="getRefund(scope.row)">退款</el-button>
      </template>
      
      <template slot-scope="{}" slot="rpiNoSearch">
        <select-page
          ref="searchRpiSelect"
          label="rpiName"
          value="rpiNo"
          :select.sync="search.rpiNo"
          :url="website.searchLink.merchantUrl"
          placeholder-text="商户"
          filter-key="searchParam"
          :params="{rpiGroup:selectMer.rpiNo}"
          @update:select="searchrpiNoChange"  @clear:select="searchrpiNoClear"
        ></select-page>
      </template>

      <template slot-scope="{}" slot="rpsNoSearch">
        <select-page
          ref="searchrpsSelect"
          label="rpsName"
          value="rpsNo"
          :select.sync="search.rpsNo"
          :url="website.searchLink.rpsUrl"
          placeholder-text="门店"
          filter-key="searchParam"
          :params="searchParams"
          @update:select="searchrpsNoChange" @clear:select="searchrpsNoClear"
        ></select-page>
      </template>

      <template slot-scope="{}" slot="rpstNoSearch">
        <select-page
          ref="searchrpstSelect"
          label="rpstName"
          value="rpstNo"
          :select.sync="search.rpstNo"
          :url="website.searchLink.rpstUrl"
          placeholder-text="操作员"
          filter-key="searchParam"
          :params="searchParams"
        ></select-page>
      </template>

      <template slot-scope="{disabled,size}" slot="beginTimeSearch">
        <el-date-picker v-model="search.beginTime" type="date" value-format='yyyy-MM-dd' @change="beginTimeChange" placeholder="请输入交易开始日期"></el-date-picker>
      </template>
      <template slot-scope="{disabled,size}" slot="endTimeSearch">
        <el-date-picker v-model="search.endTime" type="date" value-format='yyyy-MM-dd' @change="endTimeChange" placeholder="请输入交易结束日期"></el-date-picker>
      </template>
    </avue-crud>
    
    <!-- 退款 -->
    <el-dialog
      title="退款"
      append-to-body
      width="440px"
      :close-on-click-modal="false"
      v-if="refundShow"
      :visible.sync="refundShow"
      :before-close="handleCloseRefund"
    >
      <el-form :model="towPwdForm" ref="refundForm" label-width="0" class="demo-ruleForm">
        <el-form-item label="">
          <el-input disabled :value="'退款金额：'+towPwdForm.payAmt+'元'" autocomplete="off" placeholder="输入二级密码"></el-input>
        </el-form-item>
        <el-form-item
          label=""
          prop="refundRemark"
          :rules="[
            { required: true,message: '二级退款备注不能为空', trigger: ['change','blur']},
          ]"
          >
          <el-input type="textarea" :rows="2" placeholder="请输入退款备注" v-model="towPwdForm.refundRemark"> </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :disabled="disabledBtn" @click="refundSubmit">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 二级密码 -->
    <el-dialog
      title="二级密码"
      append-to-body
      width="300px"
      top="18vh"
      :close-on-click-modal="false"
      v-if="twoPwdShow"
      :visible.sync="twoPwdShow"
      :before-close="handleCloseTwoPwd"
    >
      <el-form :model="towPwdForm" ref="towPwdForm" label-width="0" class="demo-ruleForm">
        <el-form-item
          label=""
          prop="towPwd"
          :rules="[
            { required: true,message: '二级密码不能为空', trigger: ['change','blur']},
            { pattern: /^[0-9]{6}$/, message: '二级密码由6位数字组成', trigger: ['change','blur']}
          ]"
          >
          <el-input show-password v-model.number="towPwdForm.towPwd" autocomplete="off" placeholder="输入二级密码"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="twoPwdSubmit()">确 定</el-button>
      </div>
    </el-dialog>

    
  </basic-container>
</template>

<script>
import {getTableTop,getAmount,getList,getExport,refundOrder} from "@/api/rb-merchant/feetMer/feet_user_trade";
import { mapGetters } from "vuex";
import selectPage from "@/components/select-page/select-page";
import { userHasInfo } from "@/api/rb-merchant/forgetPassword/forgetPassword";
import md5 from 'js-md5';


export default {
  components: {
    selectPage
  },
  data() {
    return {
      disabledBtn:false,
      refundShow:false,
      towPwdForm:{
        payAmt:'',
        towPwd:'',
        refundRemark:''
      },
      twoPwdShow:false,
      hasPayPwd:false,
      formCode:'',
      searchRadioArr : [],//单选
      searchTextArr : [],//文本
      searchDateArr : [],//时间
      cardOption: {
        span: 4,
        animation:false,
        data: [
          {
            count: 0,
            title: '订单总金额',
          },
          {
            count: 0,
            title: '总笔数',
          },
          {
            count: 0,
            title: '退款金额'
          },
          {
            count: 0,
            title: '退款笔数'
          },
          {
            count: 0,
            title: '实收金额'
          },
          {
            count: 0,
            title: '实收笔数'
          }
        ]
      },
      form: {},
      query: {},
      search: {},
      loading: false,
      excelBox: false,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        height: "auto",
        calcHeight: 30,
        tip: false,
        border: true,
        index: true,
        viewBtn: false,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        selection: false,
        // searchMenuSpan: 6,
        searchLabelWidth: 120,
        menuWidth: 100,
        columnBtn: false,
        searchIcon: true,
        searchIndex: 3,
        indexLabel: "序号",
        column: [
          {
            label: "支付单号",
            prop: "rptOrderCode",
            type: "input",
            minWidth: 140,
            overHidden: true,
            search:true
          },
          {
            label: "缴费单号",
            prop: "orderCode",
            type: "input",
            minWidth: 140,
            overHidden: true,
            search:true
          },
          {
            label: "商户号",
            searchLabel:'商户',
            prop: "rpiNo",
            type: "input",
            minWidth: 140,
            overHidden: true,
            search:false
          },
          {
            label: "商户名称",
            prop: "rpiName",
            type: "input",
            minWidth: 140,
            overHidden: true,
          },
          {
            label: "门店编号",
            searchLabel:'门店',
            prop: "rpsNo",
            type: "input",
            minWidth: 140,
            overHidden: true,
            search:false
          },
          {
            label: "门店名称",
            prop: "rpsName",
            type: "input",
            minWidth: 140,
            overHidden: true,
          },
          {
            label: "操作员编号",
            searchLabel:'操作员',
            prop: "rpstNo",
            type: "input",
            minWidth: 140,
            overHidden: true,
            search:false
          },
          {
            label: "操作员名称",
            prop: "rpstName",
            type: "input",
            minWidth: 140,
            overHidden: true,
          },
          {
            label: "订单总金额",
            prop: "payAmt",
            type: "input",
            minWidth: 140,
            overHidden: true,
          },
          {
            label: "交易时间",
            prop: "payTime",
            type: "input",
            minWidth: 140,
            overHidden: true,
          },
          {
            label: "订单状态",
            prop: "payStatus",
            type: "select",
            minWidth: 140,
            overHidden: true,
            hide: false,
            search: true,
            dicData: [
              {
                label: "未支付",
                value: 0
              },
              {
                label: "支付成功",
                value: 1
              },
              {
                label: "退款成功",
                value: 2
              }
            ]
          },
          {
            label: "订单状态",
            prop: "payStatusName",
            type: "input",
            minWidth: 140,
            overHidden: true
          },
          {
            label: "官方订单号",
            prop: "rptOtherPayCode",
            type: "input",
            minWidth: 140,
            overHidden: true,
            search:true
          },
          {
            label: "交易方式",
            prop: "payWay",
            type: "select",
            minWidth: 140,
            overHidden: true,
            hide: true,
            search: true,
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "number",
            dicUrl: "/api/blade-system/dict/dictionary?code=rpt_pay_type"
          },
          {
            label: "交易方式",
            prop: "payWayName",
            type: "input",
            minWidth: 140,
            overHidden: true,
          },
          {
            label: "付款人",
            prop: "openId",
            type: "input",
            minWidth: 140,
            overHidden: true,
          },
          {
            label: "终端号",
            prop: "rtNo",
            type: "input",
            minWidth: 140,
            overHidden: true,
            search:true
          },
          {
            label: "交易完成日期",
            prop: "paymentCompletionDate",
            type: "input",
            minWidth: 140,
            overHidden: true,
          },
          {
            label: "交易开始日期",
            prop: "beginTime",
            search: true,
            hide: true,
            display: false
          },
          {
            label: "交易结束日期",
            prop: "endTime",
            search: true,
            hide: true,
            display: false
          }
        ]
      },
      data: [],
      searchParams:{}
    };
  },
  computed: {
    ...mapGetters(["permission","selectMer"]),
    // permissionList() {
    //   return {
    //     addBtn: this.vaildData(this.permission.feet_user_trade_add, false),
    //     viewBtn: this.vaildData(this.permission.feet_user_trade_view, false),
    //     delBtn: this.vaildData(this.permission.feet_user_trade_delete, false),
    //     editBtn: this.vaildData(this.permission.feet_user_trade_edit, false),
    //   };
    // },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    }
  },
  created(){
    /** 是否 有二级密码 */
    this.getUserHasInfo();
    /* 检测是否选择了商户，没有选择跳转页面进行选择 */
    this.isSelect();
    /** 遍历 自定义表头 */
    this.mapTable();
  },
  methods: {
    refundSubmit(){
      this.towPwdForm.refundRemark
      this.$refs.refundForm.validate((valid) => {
        if (valid) {
          this.twoPwdShow = true;
        } else {
          return false;
         }
      })
    },
    /** @desc 退款
      *二级密码 关闭回调 */
    handleCloseTwoPwd(done){
      this.towPwdForm.towPwd="";
      done()
    },
    /** @desc 退款
      *备注 关闭回调 */
    handleCloseRefund(done){
      this.towPwdFormInit();
      done()
    },
    towPwdFormInit(){
      this.towPwdForm.payAmt="";
      this.towPwdForm.towPwd="";
      this.towPwdForm.refundRemark="";
    },
    /* 二级密码 确定 */
    twoPwdSubmit(){
      let _that = this;
      this.$refs.towPwdForm.validate((valid) => {
        if (valid) {
          let params ={
            refundRemark: _that.towPwdForm.refundRemark, 
            rptOrderNo: _that.towPwdForm.rptOrderNo, 
            payPwd:md5(_that.towPwdForm.towPwd+'')
          }
          _that.disabledBtn = true;
          refundOrder(params).then(() => {
            _that.refundShow = false;
            _that.twoPwdShow = false;
            _that.towPwdFormInit();
            _that.disabledBtn = false;

            _that.$message({
              type: "success",
              message: "退款成功!"
            });
            _that.onLoad(this.page);
          },(error) => {
            window.console.log(error);
            _that.disabledBtn = false;
          });
        } else {
          return false;
         }
      });
    },
    /* 退款 dialog */
    getRefund(row) {
      this.towPwdForm.rptOrderNo = row.rptOrderCode;
      this.towPwdForm.payAmt=row.payAmt;

      this.refundShow = true
    },
    
    /** 是否 有二级密码 */
    getUserHasInfo(){
      userHasInfo().then(res =>{
        this.hasPayPwd = res.data.data.hasPayPwd;
        if(res.data.data.hasPayPwd === false){
          this.$confirm('请您先设置二级密码，再操作！', '提示', {
            confirmButtonText: '确定',
            showCancelButton:false,
            type: 'warning'
          }).then(() => {
            this.$router.push({ path: '/info/index', query: { index: 1 }})
          })
        }
      })
    },
    /** 遍历 自定义表头 */
    mapTable(){
      this.formCode = this.$route.query.formCode;
      let data = [];
      getTableTop(this.formCode).then(res =>{
        data = res.data.data;
        if(data.length>0){ 
          data.forEach(item =>{
            // moduleAttribute	组件属性
            // (0单选 1多选 2文本输入 3文案 4日期 5协议组件, 6标准金额 7固定金额 8单选金额 9多选金额)	integer
            // moduleAttributeName	组件属性名称	string

            // moduleType	组件类型(0基础组件 1金额组件)	integer
            // moduleTypeName	组件类型名称
            let ele = {};
            switch(item.moduleAttribute){
              // 0单选
              case 0:
                ele = {
                  label: item.moduleKey,
                  prop: item.elementId,
                  type: "select",
                  search: item.isSelect===1?true:false,
                  // search: true,
                  // dicData: item.moduleOption?JSON.parse(item.moduleOption):[],
                  dicData: [],
                  overHidden: true,
                  props: {
                    label: 'opKey',
                    value: 'opValue'
                  }
                }
                if(item.moduleOption){
                  ele.dicData = JSON.parse(item.moduleOption).map((e,index)=>{
                    return {
                      opKey:e.opKey,
                      opValue:index
                    }
                  })
                }
                
                this.option.column.push(ele);
                this.searchRadioArr.push(ele);
                break
              //1多选
              case 1:
                ele = {
                  label: item.moduleKey,
                  prop: item.elementId,
                  overHidden: true,
                  search: false,
                  hide: false
                }
                this.option.column.push(ele);
                break
              // 2文本
              case 2:
                ele = {
                  label: item.moduleKey,
                  prop: item.elementId,
                  overHidden: true,
                  search: item.isSelect===1?true:false
                  // search: true,
                }

                this.option.column.push(ele);
                this.searchTextArr.push(ele);
                break
              // 3文案
              case 3:
                ele = {
                  label: item.moduleKey,
                  prop: item.elementId,
                  overHidden: true,
                  search: false,
                  hide: false
                }
                this.option.column.push(ele);
                break
              // 4日期
              case 4:
                ele = {
                  label: item.moduleKey,
                  prop: item.elementId,
                  overHidden: true,
                  minWidth: 140,
                  search: item.isSelect===1?true:false
                  // search: true,
                }
                /* (0日 1月 2年) */
                if(item.dateType === 0 ){
                  ele.format = 'yyyy-MM-dd';
                  ele.valueFormat = 'yyyy-MM-dd';
                  ele.type = "date";
                }else if(item.dateType === 1 ){
                  ele.format = 'yyyy-MM';
                  ele.valueFormat = 'yyyy-MM';
                  ele.type = "month";
                }else if(item.dateType === 2 ){
                  ele.format = 'yyyy';
                  ele.valueFormat = 'yyyy';
                  ele.type = "year";
                }

                this.option.column.push(ele);
                this.searchDateArr.push(ele);
                break
              // 5协议组件
              case 5:
                ele = {
                  label: item.moduleKey,
                  prop: item.elementId,
                  search: false,
                  hide: false
                }
                this.option.column.push(ele);
                break
              // 6标准金额
              case 6:
                ele = {
                  label: item.moduleKey,
                  prop: item.elementId,
                  minWidth: 140,
                  overHidden: true,
                  search: false,
                }
                this.option.column.push(ele);
                break
              // 7固定金额
              case 7:
                ele = {
                  label: item.moduleKey,
                  prop: item.elementId,
                  minWidth: 140,
                  overHidden: true,
                  search: false,
                }
                this.option.column.push(ele);
                break
              // 8单选金额
              case 8:
                ele = {
                  label: item.moduleKey,
                  prop: item.elementId,
                  overHidden: true,
                  minWidth: 140,
                  search: false,
                }
                this.option.column.push(ele);
                break
              // 9多选金额
              case 9:
                ele = {
                  label: item.moduleKey,
                  prop: item.elementId,
                  minWidth: 140,
                  search: false,
                  overHidden: true,
                }
                this.option.column.push(ele);
                break
            }
          })
        }
      })

      this.onLoad(this.page);
      
    },
    isSelect(){
      /* userMerchantType----用户商户类型(0.无 1.集团商户 2.商户 3.门店 4.收银员) */
      if(this.selectMer.userMerchantType === 1){
        // 集团商户
        this.searchParams.rpiGroup = this.selectMer.rpiNo;

        const selectRpiNo = this.findObject(this.option.column, "rpiNo");
        const selectRpsNo = this.findObject(this.option.column, "rpsNo");
        const selectRpstNo = this.findObject(this.option.column, "rpstNo");
        selectRpiNo.search = true;
        selectRpsNo.search = true;
        selectRpstNo.search = true;

      }else if(this.selectMer.userMerchantType === 2){
        // 商户
        this.searchParams.rpiNo = this.selectMer.rpiNo;

        const selectRpsNo = this.findObject(this.option.column, "rpsNo");
        const selectRpstNo = this.findObject(this.option.column, "rpstNo");
        selectRpsNo.search = true;
        selectRpstNo.search = true;
      }else if(this.selectMer.userMerchantType === 3){
        // 门店
        this.searchParams={
          rpiNo:this.selectMer.rpiNo,
          rpsNo:this.selectMer.rpsNo
        }

        const selectRpstNo = this.findObject(this.option.column, "rpstNo");
        selectRpstNo.search = true;
      }else{
        // 操作员
        this.searchParams={
          rpiNo:this.selectMer.rpiNo,
          rpsNo:this.selectMer.rpsNo,
          rpstNo:this.selectMer.rpstNo
        }
      }
    },
    /** 列表--查询商户*/
    searchrpiNoChange(value){
      if (value) {
        this.search.rpsNo = "";
        this.search.rpstNo = "";
        this.searchParams.rpiNo = value;

        let params = {
          rpiNo: value
        };
        this.$refs['searchrpsSelect'].getOptionList(params);
        this.$refs['searchrpstSelect'].getOptionList(params);
      }
    },
    /** 列表--查询商户*/
    searchrpiNoClear(){
      this.search.rpsNo = "";
      this.search.rpstNo = "";
      this.searchParams.rpiNo = "";

      this.$refs['searchrpsSelect'].getOptionList({rpiGroup:this.selectMer.rpiNo});
      this.$refs['searchrpstSelect'].getOptionList({rpiGroup:this.selectMer.rpiNo});
    },
    /** 列表--查询门店*/
    searchrpsNoChange(value){
      if (value) {
        this.search.rpstNo = "";

        let params = {
          rpsNo: value,
          rpiNo:this.searchParams.rpiNo
        };
        this.$refs['searchrpstSelect'].getOptionList(params);
      }
    },
    /** 列表--查询门店*/
    searchrpsNoClear(){
      this.search.rpstNo = "";

      this.$refs['searchrpstSelect'].getOptionList(this.searchParams);
    },
    beginTimeChange() {
      if(this.search.endTime){
        if(Date.parse(this.search.beginTime) > Date.parse(this.search.endTime)){
          this.$alert('交易开始日期不能大于结束日期', '提示', {
            confirmButtonText: '确定',
            type: 'warning'
          })
          .then(() => (this.search.beginTime = ""))
          .catch(() => (this.search.beginTime = ""))
        }
      }
    },
    endTimeChange() {
      if(this.search.beginTime){
        if(Date.parse(this.search.endTime) < Date.parse(this.search.beginTime)){
          this.$alert('交易结束日期不能小于开始日期', '提示', {
            confirmButtonText: '确定',
            type: 'warning'
          })
          .then(() => (this.search.endTime = ""))
          .catch(() => (this.search.endTime = ""))
        }
      }
    },
    beforeOpen(done, type) {
      // if (["edit", "view"].includes(type)) {
      //   getDetail(this.form.id).then((res) => {
      //     this.form = res.data.data;
      //   });
      // }
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      let searchRadioArray = [];//单选查询
      let searchTextArray = [];//文本
      let searchDateArray = [];//时间


      this.searchRadioArr.forEach((item) => {
        if(params.hasOwnProperty(item.prop)){
          searchRadioArray.push(item.prop+':'+params[item.prop])
        }
      })
      this.searchTextArr.forEach((item) => {
        if(params.hasOwnProperty(item.prop)){
          searchTextArray.push(item.prop+':'+params[item.prop])
        }
      })
      this.searchDateArr.forEach((item) => {
        if(params.hasOwnProperty(item.prop)){
          searchDateArray.push(item.prop+':'+params[item.prop])
        }
      })

      this.query = {
        ...params,
        searchRadio:searchRadioArray.length>0?searchRadioArray.join("|"):"",
        searchText:searchTextArray.length>0?searchTextArray.join("|"):"",
        searchDate:searchDateArray.length>0?searchDateArray.join("|"):""
      }
      
      this.page.currentPage = 1;
      this.onLoad(this.page);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page);
    },
    onLoad(page, params = {}) {
      // this.loading = true;
      let paramObj = {
        formCode:this.formCode
      }
      if(this.selectMer.userMerchantType === 1){
        // 集团商户
        paramObj.rpiGroup=this.selectMer.rpiNo;
      }else if(this.selectMer.userMerchantType === 2){
        // 商户
        paramObj.rpiNo=this.selectMer.rpiNo;
        if(!this.query.rpstNo){
          paramObj.rpstNo=this.selectMer.rpstNo;
        }
      }else if(this.selectMer.userMerchantType === 3){
        // 门店
        paramObj.rpsNo = this.selectMer.rpsNo;
        paramObj.rpiNo=this.selectMer.rpiNo;
        if(!this.query.rpstNo){
          paramObj.rpstNo=this.selectMer.rpstNo;
        }
      }else if(this.selectMer.userMerchantType === 4){
        // 收银员
        paramObj.rpstNo = this.selectMer.rpstNo;
        paramObj.rpiNo=this.selectMer.rpiNo;
      }
      // 列表
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query, paramObj)).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        
        if(data.records.length>0){
          data.records.forEach(ele =>{
            Object.assign(ele,ele.additional)
          })
          this.data = data.records;
        }else{
          this.data = [];
        }
        this.$nextTick(() => {
          this.$refs.crud.doLayout();
        });
        this.loading = false;
        this.$forceUpdate()
      });
      // 统计
      getAmount(Object.assign(params, this.query, paramObj)).then(res => {
        let amount = res.data.data;
        this.cardOption.data[0].count = amount.totalAmount;
        this.cardOption.data[1].count = amount.totalCount;
        this.cardOption.data[2].count = amount.totalRefund;
        this.cardOption.data[3].count = amount.totalRefundCount;
        this.cardOption.data[4].count = amount.realAmount;
        this.cardOption.data[5].count = amount.realCount;
      })
    },
    handleExport() {
      this.$confirm("是否导出用户数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        let paramObj = {
          formCode:this.formCode
        }
        if(this.selectMer.userMerchantType === 1){
          // 集团商户
          paramObj.rpiGroup=this.selectMer.rpiNo;
        }else if(this.selectMer.userMerchantType === 2){
          // 商户
          paramObj.rpiNo=this.selectMer.rpiNo;
          if(!this.query.rpstNo){
            paramObj.rpstNo=this.selectMer.rpstNo;
          }
        }else if(this.selectMer.userMerchantType === 3){
          // 门店
          paramObj.rpsNo = this.selectMer.rpsNo;
          paramObj.rpiNo=this.selectMer.rpiNo;
          if(!this.query.rpstNo){
            paramObj.rpstNo=this.selectMer.rpstNo;
          }
        }else if(this.selectMer.userMerchantType === 4){
          // 收银员
          paramObj.rpstNo = this.selectMer.rpstNo;
          paramObj.rpiNo=this.selectMer.rpiNo;
        }
        
        getExport(Object.assign(this.query, paramObj)).then((res) => {
          this.$message({ type: "success",message: res.data.msg });
        })
      });
    },
    sortChange(val) {
      if (val.order == "ascending") {
        //正序
        this.query.ascs = val.prop;
        this.query.descs = "";
      } else {
        //倒序
        this.query.descs = val.prop;
        this.query.ascs = "";
      }
      this.refreshChange();
    },
  },
};
</script>

<style lang="scss" scoped>
/deep/ .avue-crud__menu{
  flex-direction: column !important;
}
/deep/ .avue-crud__right{
  align-self: flex-end !important;
}
/deep/ .el-input.is-disabled .el-input__inner{
  background-color: #fff !important;
}
</style>
